package nl.vu.few.ibivu.biomodels.client.event;

import com.google.gwt.event.shared.EventBus;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.HandlerRegistration;

public class RequestModelOperationEvent extends GwtEvent<RequestModelOperationEventHandler> {

	public static Type<RequestModelOperationEventHandler> TYPE = new Type<RequestModelOperationEventHandler>();
	private ModelOperation operation;
	
	public RequestModelOperationEvent(ModelOperation operation) {
		super();
		this.operation = operation;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<RequestModelOperationEventHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(RequestModelOperationEventHandler handler) {
		handler.onOperationRequest(this);
	}

	public static HandlerRegistration register(EventBus eventBus, RequestModelOperationEventHandler handler) {
		return eventBus.addHandler(TYPE, handler);
	}

	public ModelOperation getOperation() {
		return operation;
	}
}
